//
//  BaseCollectionVC.swift
//  JTYP
//
//  Created by Groot on 2017/12/13.
//  Copyright © 2017年 inspur. All rights reserved.
//
import MJRefresh

public class BaseCollectionVC: UICollectionViewController, UICollectionViewDelegateFlowLayout {
    
    // RefreshFooter
    internal var mjRefreshFooter: MJRefreshAutoNormalFooter? {
        let footer = MJRefreshAutoNormalFooter.init {[unowned self] in
            self.loadMore()
        }
        footer?.isRefreshingTitleHidden = true
        footer?.setTitle("", for: .idle)
        footer?.setTitle("—— 我是有底线的 ——", for: .noMoreData)
        footer?.stateLabel.font = UIFont.systemFont(ofSize: 13)
        footer?.stateLabel.textColor = UIColor.init(white: 0.7, alpha: 0.7)
        footer?.isAutomaticallyChangeAlpha = true
        return footer
    }
    
    internal var mjRefreshHeader: ALoadingHeader? {
        let header = ALoadingHeader.init(refreshingTarget: self, refreshingAction: #selector(reload))
        return header
    }
    
    internal lazy var bgPlaceholderView: UIImageView = {
        var v = UIImageView.init(frame: self.view.bounds)
        v.image = UIImage.init(named: "channelPagePlaceholder")
        v.isUserInteractionEnabled = true
        return v
    }()
    
    internal lazy var errorPageView: ViewLoadingPage = {
        var v = ViewLoadingPage.init(frame: self.view.bounds)
        return v
    }()
    
    override public func viewDidLoad() {
        super.viewDidLoad()
        
        self.collectionView?.backgroundColor = UIColor.init(hex: "fAfAfA")
        
        // Refresh Header & Footer
        self.collectionView?.mj_header = mjRefreshHeader
        self.collectionView?.mj_footer = mjRefreshFooter
        self.view.addSubview(bgPlaceholderView)
    }
    
    
    @objc func reload() {
        
    }
    
    @objc func loadMore() {
        
    }
}
